/**
 * @author YinHang
 */
;(function () {
	var g2d = Gamepackage.get("Gamepackage.ui.g2d");
	g2d.Graphics = function (context) {
		this.context = context;
		this.textBuffer = {};
	};
	
	var Prototype = g2d.Graphics.prototype;
	
	Prototype.getContext = function () {
		return this.context;
	};
	
	Prototype.drawRect = function (color, x, y, width, height) {
		this.context.strokeStyle = color;
		this.context.strokeRect(x, y, width, height);
	};

	Prototype.drawArcs = function (color, x, y, radius, startAngle, endAngle, anticlockwise) {
		this.context.beginPath();
		this.context.strokeStyle = color;
		this.context.arc(x, y, radius, startAngle, endAngle, anticlockwise);
		this.context.stroke();
	};

	Prototype.fillArcs = function (color, x, y, radius, startAngle, endAngle, anticlockwise) {
		this.context.beginPath();
		this.context.fillStyle = color;
		this.context.arc(x, y, radius, startAngle, endAngle, anticlockwise);
		this.context.fill();
	};
	
	Prototype.fillRect = function (color, x, y, width, height) {
		this.context.beginPath();
		this.context.fillStyle = color;
        this.context.fillRect(x, y, width, height);
		this.context.fill();
	};
	
	Prototype.drawImage = function (image, x, y, width, height) {
		if(image.loaded)
			this.context.drawImage(image.getSourceImage(), x, y, width || image.getWidth(), height || image.getHeight());
	};
	
	Prototype.drawCanvas = function (canvas, x, y, width, height) {
		this.context.drawImage(canvas.getSourceCanvas(), x, y, width || image.getWidth(), height || image.getHeight());
	};
	
	Prototype.drawSlice = function (image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
		if(image.loaded)
			this.context.drawImage(image.getSourceImage(), sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
	};
})();
